// pages/contact/index/index.js
Page({
  data: {
    fullName:'',
    cellphone:'',
    city:'',
    idNumber:'',
    bankName:'',
    bankAccount:'',
    userName:'',
    userCode:'',
    cityArray: ['北京', '上海','成都','青岛', '济南','郑州','南京','西安','合肥','武汉','苏州','石家庄'],
    index: 0,
    openId: ''
    
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    this.setData({
            fullName:options.fullName,
            cellphone:options.cellphone,
            city:options.city,
            idNumber:options.idNumber,
            bankName:options.bankName,
            bankAccount:options.bankAccount,
            userName:options.userName,
            userCode:options.userCode,
        })
  },
  textinput:function(e){
    var type = e.currentTarget.dataset.type;
        if (type == 1) {
            this.setData({
                idNumber: e.detail.value
            });
        }
        if (type == 2) {
            this.setData({
                bankName: e.detail.value
            });
        }
        if (type == 3) {
            this.setData({
                bankAccount: e.detail.value
            });
        }
       
  },
  
  bindPickerCity: function(e) {
    this.setData({
      index: e.detail.value
    })
  },

  edit:function(){
    var that = this;
    wx.request({
      url: 'http://10.33.50.23:8080/wxAppletContact/updateContact',    
      data: {
           fullName:that.data.fullName,
           cellphone:that.data.cellphone,
           city:that.data.city,
           idNumber:that.data.idNumber,
           bankName:that.data.bankName,
           bankAccount:that.data.bankAccount,
           userName:that.data.userName,
           userCode:that.data.userCode,
      },
      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function(res){
        console.log("success")
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
      }
    })
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})